Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the BlogComments class.
	''' </summary>
	<Serializable> _
	Public Partial Class BlogCommentsCollection 
	Inherits ActiveList(Of BlogComments, BlogCommentsCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the BlogComments table.
	''' </summary>
	<Serializable> _
	Public Partial Class BlogComments 
	Inherits ActiveRecord(Of BlogComments)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("BlogComments", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarCommentid As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarCommentid.ColumnName = "commentid"
                colvarCommentid.DataType = DbType.Int32
                colvarCommentid.MaxLength = 0
                colvarCommentid.AutoIncrement = true
                colvarCommentid.IsNullable = false
                colvarCommentid.IsPrimaryKey = true
                colvarCommentid.IsForeignKey = false
                colvarCommentid.IsReadOnly = false
                
                
                schema.Columns.Add(colvarCommentid)
                
                Dim colvarPostid As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarPostid.ColumnName = "postid"
                colvarPostid.DataType = DbType.Int32
                colvarPostid.MaxLength = 0
                colvarPostid.AutoIncrement = false
                colvarPostid.IsNullable = false
                colvarPostid.IsPrimaryKey = false
                colvarPostid.IsForeignKey = false
                colvarPostid.IsReadOnly = false
                
                
                schema.Columns.Add(colvarPostid)
                
                Dim colvarName As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarName.ColumnName = "Name"
                colvarName.DataType = DbType.String
                colvarName.MaxLength = 500
                colvarName.AutoIncrement = false
                colvarName.IsNullable = false
                colvarName.IsPrimaryKey = false
                colvarName.IsForeignKey = false
                colvarName.IsReadOnly = false
                
                
                schema.Columns.Add(colvarName)
                
                Dim colvarEmail As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEmail.ColumnName = "Email"
                colvarEmail.DataType = DbType.String
                colvarEmail.MaxLength = 500
                colvarEmail.AutoIncrement = false
                colvarEmail.IsNullable = false
                colvarEmail.IsPrimaryKey = false
                colvarEmail.IsForeignKey = false
                colvarEmail.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEmail)
                
                Dim colvarComment As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarComment.ColumnName = "Comment"
                colvarComment.DataType = DbType.String
                colvarComment.MaxLength = 8000
                colvarComment.AutoIncrement = false
                colvarComment.IsNullable = false
                colvarComment.IsPrimaryKey = false
                colvarComment.IsForeignKey = false
                colvarComment.IsReadOnly = false
                
                
                schema.Columns.Add(colvarComment)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("BlogComments",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("Commentid")> _
        Public Property Commentid As Integer 
			Get
				Return GetColumnValue(Of Integer)("commentid")
			End Get
		    
			Set
				SetColumnValue("commentid", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Postid")> _
        Public Property Postid As Integer 
			Get
				Return GetColumnValue(Of Integer)("postid")
			End Get
		    
			Set
				SetColumnValue("postid", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Name")> _
        Public Property Name As String 
			Get
				Return GetColumnValue(Of String)("Name")
			End Get
		    
			Set
				SetColumnValue("Name", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Email")> _
        Public Property Email As String 
			Get
				Return GetColumnValue(Of String)("Email")
			End Get
		    
			Set
				SetColumnValue("Email", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Comment")> _
        Public Property Comment As String 
			Get
				Return GetColumnValue(Of String)("Comment")
			End Get
		    
			Set
				SetColumnValue("Comment", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varPostid As Integer,ByVal varName As String,ByVal varEmail As String,ByVal varComment As String)
			Dim item As BlogComments = New BlogComments()
			
            item.Postid = varPostid
            
            item.Name = varName
            
            item.Email = varEmail
            
            item.Comment = varComment
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varCommentid As Integer,ByVal varPostid As Integer,ByVal varName As String,ByVal varEmail As String,ByVal varComment As String)
			Dim item As BlogComments = New BlogComments()
		    
                item.Commentid = varCommentid
				
                item.Postid = varPostid
				
                item.Name = varName
				
                item.Email = varEmail
				
                item.Comment = varComment
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared Commentid As String = "commentid"
            
            Public Shared Postid As String = "postid"
            
            Public Shared Name As String = "Name"
            
            Public Shared Email As String = "Email"
            
            Public Shared Comment As String = "Comment"
            
		End Structure
		#End Region
	End Class
End Namespace
